﻿using NationalInstruments.DAQmx;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using 低频天线阵列相控阵信号发生系统SmartFASK12.Models;

namespace 低频天线阵列相控阵信号发生系统SmartFASK12.Controls
{
    public class MEvent
    {
        /// <summary>SS
        /// 发送
        /// </summary>
        public event EventHandler<SampleQuantityMode> HasSendVoltage;
        /// <summary>
        /// 电压任务完成
        /// </summary>
        public event EventHandler HasVoltageOutputCompleted;
        /// <summary>
        /// 开始执行事件
        /// </summary>
        public event EventHandler HasStartExecution;
        /// <summary>
        /// 显示抽样判决点
        /// </summary>
        public event EventHandler HasShowJudgePoint;
        /// <summary>
        /// 更新显示点数事件
        /// </summary>
        public event EventHandler HasUpdataShowPoint;
        /// <summary>
        /// 解调
        /// </summary>
        public event EventHandler HasDemodulation;
        /// <summary>
        /// 开始采集
        /// </summary>
        public event EventHandler<bool> HasStartCollection;
        /// <summary>
        /// 停止采集
        /// </summary>
        public event EventHandler HasStopAcquisition;
        /// <summary>
        /// 导出Excel
        /// </summary>
        public event EventHandler HasExcelOut;
        /// <summary>
        /// 点击显示曲线
        /// </summary>
        public event EventHandler<CalSingalInfo> HasViewCurve;
        /// <summary>
        /// 导入Excel
        /// </summary>
        public event EventHandler HasImportExcel;
        private static MEvent _instance = null;
        private MEvent()
        {

        }

        public static MEvent Singleton()
        {
            if (_instance == null)
            {
                _instance = new MEvent();
            }

            return _instance;
        }

        /// <summary>
        /// 主界面主动停止
        /// </summary>
        /// <param name="comtaskId"></param>
        public void EmitVoltageOutputCompleted()
        {
            HasVoltageOutputCompleted?.Invoke(this, null);
        }

        /// <summary>
        /// 开始执行事件
        /// </summary>
        /// <param name="comtaskId"></param>
        public void EmitStartExecution()
        {
            HasStartExecution?.Invoke(this, null);
        }

        /// <summary>
        /// 显示抽样判决点事件
        /// </summary>
        /// <param name="comtaskId"></param>
        public void EmitShowJudgePoint()
        {
            HasShowJudgePoint?.Invoke(this, null);
        }

        /// <summary>
        /// 更新显示点数事件
        /// </summary>
        /// <param name="comtaskId"></param>
        public void EmitUpdataShowPoint()
        {
            HasUpdataShowPoint?.Invoke(this, null);
        }

        /// <summary>
        /// 解调事件
        /// </summary>
        /// <param name="comtaskId"></param>
        public void EmitDemodulation()
        {
            HasDemodulation?.Invoke(this, null);
        }

        /// <summary>
        /// 开始采集
        /// </summary>
        /// <param name="comtaskId"></param>
        public void EmitStartCollection(bool IsManual = false)
        {
            HasStartCollection?.Invoke(this, IsManual);
        }

        /// <summary>
        /// 停止采集
        /// </summary>
        /// <param name="comtaskId"></param>
        public void EmitStopAcquisition()
        {
            HasStopAcquisition?.Invoke(this, null);
        }

        /// <summary>
        /// 导出Excel
        /// </summary>
        /// <param name="comtaskId"></param>
        public void EmitExcelOut()
        {
            HasExcelOut?.Invoke(this, null);
        }
        /// <summary>
        /// 发送电压
        /// </summary>
        /// <param name="comtaskId"></param>
        public void EmitSendVoltage(SampleQuantityMode sampleQuantityMode)
        {
            HasSendVoltage?.Invoke(this, sampleQuantityMode);
        }
        /// <summary>
        /// 显示曲线
        /// </summary>
        /// <param name="comtaskId"></param>
        public void EmitViewCurve(CalSingalInfo calSingalInfo)
        {
            HasViewCurve?.Invoke(this, calSingalInfo);
        }

        /// <summary>
        /// 导入数据
        /// </summary>
        /// <param name="comtaskId"></param>
        public void EmitImportExcel()
        {
            HasImportExcel?.Invoke(this, null);
        }
        
    }
}
